﻿<%@ WebHandler Language="C#" Class="category" %>
using Models;
using System;
using System.Web;
using Newtonsoft.Json;
using System.Linq;
using System.Collections;
public class category : IHttpHandler {

    public void ProcessRequest(HttpContext context) {
        context.Response.ContentType = "text/plain";

        //string query = HttpContext.Current.Request.Params["id"];
        //if (string.IsNullOrEmpty(query))
        //{
        //    HttpContext.Current.Response.Write("parameter error");
        //    return;
        //}


        var code = 1;
        var msg = "商城分类";
        var time = DateTime.Now;



        using (Entities bll = new Entities())
        {
            var children = bll.S_Classs.Where(n => n.SCpareID == 0).Select(x => new
            {
                //image="https://api.7wpp.com/uploads/20201209/ea0eef9b5e58af66347cfd8fa5d5e308.png",
                id = x.SCID+10,
                name = x.SCNmae,
                x.SCpareID,
                x.SCUrl,
                type = "",
                children=new ArrayList(),
                pid=1,
                weigh=0
            }).ToList();
            var id = 1;
            var type = "2";
            var name="分类";
            var pid=0;
            var weigh = 0;

            var data = new { id,name,pid, type,weigh, children };
            context.Response.Write(JsonConvert.SerializeObject(new { code,msg,time,data}));

        }

        HttpContext.Current.Response.End();
        //context.Response.Write("Hello World");


    }


    public IQueryable ClassTreeBindFV(int pid)
    {
        using (Entities _class = new Entities())
        {
            var children = _class.S_Classs.Where(n => n.SCpareID == pid).Select(x => new
            {
                id = x.SCID,
                name = x.SCNmae,
                x.SCpareID,
                x.SCUrl,
                type = ""

            });
            return children;
        }
    }

    public bool IsReusable {
        get {
            return false;
        }
    }

}